package stardust.product.j2d;


import java.awt.Color;
import java.awt.Graphics;
import java.util.LinkedList;
import java.util.List;


public abstract class GraphicsObject
{

	private int x, y, width, height;
	
	private Color foregroundColor;
	private Color backroundColor;
	
	private List<GraphicsObject> graphicsObjects = new LinkedList<GraphicsObject>();
	
	protected void privatePaint(Graphics g, int x, int y)
	{
		int dx = this.x + x;
        int dy = this.y + y;

        this.paint(g, dx, dy);

        for (int i = 0; i < this.graphicsObjects.size(); i++)
        {
        	this.graphicsObjects.get(i).privatePaint(g, dx, dy);
        }
	}
	
	/**
	 * 实现此方法以实现绘图。
	 */
	public abstract void paint(Graphics g, int x, int y);
	
	public List<GraphicsObject> getGraphicsObjects()
	{
		return this.graphicsObjects;
	}

	public int getX()
	{
		return x;
	}

	public void setX(int x)
	{
		this.x = x;
	}

	public int getY()
	{
		return y;
	}

	public void setY(int y)
	{
		this.y = y;
	}

	public int getWidth()
	{
		return width;
	}

	public void setWidth(int width)
	{
		this.width = width;
	}

	public int getHeight()
	{
		return height;
	}

	public void setHeight(int height)
	{
		this.height = height;
	}

	public Color getForegroundColor()
	{
		return foregroundColor;
	}
	
	public void setForegroundColor(Color foregroundColor)
	{
		this.foregroundColor = foregroundColor;
	}
	
	public Color getBackroundColor()
	{
		return backroundColor;
	}
	
	public void setBackroundColor(Color backroundColor)
	{
		this.backroundColor = backroundColor;
	}
	
}
